﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace SupermarketDemo.Views.Customer
{
    public partial class Register : System.Web.UI.Page
    {
        Models.functions Con;
        protected void Page_Load(object sender, EventArgs e)
        {
            Con = new Models.functions();
        }
        protected void SaveBtn_Click(object sender, EventArgs e)
        {
            try
            {
                if (CNameTb.Value == "" || EmailTb.Value == "" || PhoneTb.Value == "" || PassTb.Value == ""||DPassTb.Value=="")
                {
                    ErrMsg.Text = "缺少完整信息";
                }
                else
                {
                    if(DPassTb.Value==PassTb.Value)
                    {
                        string CName = CNameTb.Value;
                        string CEmail = EmailTb.Value;
                        string CPhone = PhoneTb.Value;
                        string CAdd = PassTb.Value;
                        string Query = "insert into CustomerTb1 values('{0}','{1}','{2}','{3}')";
                        Query = string.Format(Query, CName, CEmail, CPhone, CAdd);
                        Con.SetData(Query);
                        ErrMsg.Text = "信息添加完成！";
                        CNameTb.Value = "";
                        EmailTb.Value = "";
                        PhoneTb.Value = "";
                        PassTb.Value = "";
                        DPassTb.Value = "";
                    }
                    else
                    {
                        ErrMsg.Text = "确认密码与密码不同请重试";
                        PassTb.Value = "";
                        DPassTb.Value = "";
                    }
                }
            }
            catch (Exception Ex)
            {
                ErrMsg.Text = Ex.Message;
            }
        }
    }
}